//
//  SINAStuApproveUserNameViewController.m
//  sinashebao
//
//  Created by  androidlongs on 2018/1/26.
//  Copyright © 2018年  androidlongs. All rights reserved.
//

#import "SINAStuApproveSchoolClassViewController.h"
#import "SINACircularBeadUtils.h"
#import "SINAStuApproveSelectSchoolViewController.h"
#import "SINACustomModelPickView.h"
#import "SINASchoolClassModel.h"
#import "SINAStuApproveSchoolCountController.h"
#import "SINACalendarUtils.h"


@interface SINAStuApproveSchoolClassViewController ()<CustomModelPickViewDelegate>
//学院
@property(strong,nonatomic) UILabel *studentSchoolCollegeUILabel;

//系
@property(strong,nonatomic) UILabel *studentDepartmentUILabel;
//专业
@property(strong,nonatomic) UILabel *studentSpecialtyUILabel;
//班级
@property(strong,nonatomic) UILabel *studentSchoolClassUILabel;
//入学年份
@property(strong,nonatomic) UILabel *studentSchoolYearUILabel;

//学院
@property(strong,nonatomic) NSMutableArray *schoolCollegeArray;
//系
@property(strong,nonatomic) NSMutableArray *schoolDepartMentArray;
//专业
@property(strong,nonatomic) NSMutableArray *schoolSpecialtyArray;
//班级
@property(strong,nonatomic) NSMutableArray *schoolSchoolClassArray;

//入学年份
@property(strong,nonatomic) NSMutableArray *schoolSchoolYearArray;

//选择的学院
@property(strong,nonatomic) SINASchoolClassModel *selectSchoolCollegeModel;
//选择的系
@property(strong,nonatomic) SINASchoolClassModel *selectDepartMentModel;
//选择的专业
@property(strong,nonatomic) SINASchoolClassModel *selectSpecialtyModel;
//选择的班级
@property(strong,nonatomic) SINASchoolClassModel *selectSchoolClassModel;
//选择的入学年份
@property(strong,nonatomic) SINASchoolClassModel *selectSchoolYearModel;

@end

@implementation SINAStuApproveSchoolClassViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [super initBackItem];
    SINAUserModel *userModel = [[SINACommonUserHelper share] getUserModel];
   
    if (userModel!=nil) {
        if ([userModel.identitys integerValue]==1) {
            self.navigationItem.title=@"学生认证";
        } else {
            self.navigationItem.title=@"老师认证";
        }
    } else {
        self.navigationItem.title=@"学生认证";
    }
    
    [self initViewFunction];
}

-(void) initViewFunction{
    
    
    self.schoolCollegeArray = [[NSMutableArray alloc]init];
    self.schoolDepartMentArray = [[NSMutableArray alloc]init];
    
    self.schoolSpecialtyArray = [[NSMutableArray alloc]init];
    self.schoolSchoolClassArray = [[NSMutableArray alloc]init];
    self.schoolSchoolYearArray= [[NSMutableArray alloc]init];
    
    UIScrollView *mainScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, mainW, mainH-49)];
    mainScrollView.contentSize=CGSizeMake(mainW, mainH+10);
    [self.view addSubview:mainScrollView];
    [self.view setBackgroundColor:[UIColor colorWithHexString:@"#eeeeee"]];
    
    
    WeakSelf;
    
    //学院
    UIView *itemView1 =[[UIScrollView alloc]initWithFrame:CGRectMake(0, 22, mainW, 48)];
    [itemView1 setBackgroundColor:[UIColor whiteColor]];
    [mainScrollView addSubview:itemView1];
    
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, CGRectGetHeight(itemView1.frame)/2-10, mainW-30, 21)];
    titleLabel.text=@"学院";
    [titleLabel setFont:[UIFont systemFontOfSize:16]];
    titleLabel.textColor=[UIColor colorWithHexString:@"#212121"];
    
    [itemView1 addSubview:titleLabel];
    
    UILabel *inputTextField = [[UILabel alloc]initWithFrame:CGRectMake(55, CGRectGetHeight(itemView1.frame)/2-17, mainW-45, 36)];
    
    [inputTextField setFont:[UIFont systemFontOfSize:16]];
    inputTextField.text=@"请选择你所在的学院";
    inputTextField.textColor=[UIColor colorWithHexString:@"#878787"];
    
    self.studentSchoolCollegeUILabel =inputTextField;
    
    [itemView1 addSubview:inputTextField];
    
    UIView *diviView1 =[[UIScrollView alloc]initWithFrame:CGRectMake(15, 47, mainW-30, 1)];
    [diviView1 setBackgroundColor:[UIColor colorWithHexString:@"#eeeeee"]];
    [itemView1 addSubview:diviView1];
    [[SINAUiviewClickLiserner alloc]viewClickFunction:itemView1 andWithBlick:^(UIView *view) {
        [weakSelf selectColleg];
    }];
    
    //系
    UIView *itemView2 =[[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(itemView1.frame), mainW, 48)];
    [itemView2 setBackgroundColor:[UIColor whiteColor]];
    [mainScrollView addSubview:itemView2];
    
    UILabel *titleLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(15, CGRectGetHeight(itemView1.frame)/2-10, mainW-30, 21)];
    titleLabel2.text=@"系别";
    [titleLabel2 setFont:[UIFont systemFontOfSize:16]];
    titleLabel2.textColor=[UIColor colorWithHexString:@"#212121"];
    
    [itemView2 addSubview:titleLabel2];
    
    UILabel *inputTextField2 = [[UILabel alloc]initWithFrame:CGRectMake(55, CGRectGetHeight(itemView1.frame)/2-17, mainW-45, 36)];
    
    [inputTextField2 setFont:[UIFont systemFontOfSize:16]];
    inputTextField2.text=@"请选择你所在的系";
    inputTextField2.textColor=[UIColor colorWithHexString:@"#878787"];
    
    self.studentDepartmentUILabel =inputTextField2;
    
    [itemView2 addSubview:inputTextField2];
    
    UIView *diviView2 =[[UIScrollView alloc]initWithFrame:CGRectMake(15, 47, mainW-30, 1)];
    [diviView2 setBackgroundColor:[UIColor colorWithHexString:@"#eeeeee"]];
    [itemView2 addSubview:diviView2];
    [[SINAUiviewClickLiserner alloc]viewClickFunction:itemView2 andWithBlick:^(UIView *view) {
        [weakSelf selectDepartMent];
    }];
    //专业
    UIView *itemView3 =[[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(itemView2.frame), mainW, 48)];
    [itemView3 setBackgroundColor:[UIColor whiteColor]];
    [mainScrollView addSubview:itemView3];
    
    UILabel *titleLabel3 = [[UILabel alloc]initWithFrame:CGRectMake(15, CGRectGetHeight(itemView3.frame)/2-10, mainW-30, 21)];
    titleLabel3.text=@"专业";
    [titleLabel3 setFont:[UIFont systemFontOfSize:16]];
    titleLabel3.textColor=[UIColor colorWithHexString:@"#212121"];
    
    [itemView3 addSubview:titleLabel3];
    
    UILabel *inputTextField3 = [[UILabel alloc]initWithFrame:CGRectMake(55, CGRectGetHeight(itemView3.frame)/2-17, mainW-45, 36)];
    
    [inputTextField3 setFont:[UIFont systemFontOfSize:16]];
    inputTextField3.text=@"请选择你的专业";
    inputTextField3.textColor=[UIColor colorWithHexString:@"#878787"];
    
    self.studentSpecialtyUILabel =inputTextField3;
    
    [itemView3 addSubview:inputTextField3];
    
    UIView *diviView3 =[[UIScrollView alloc]initWithFrame:CGRectMake(15, 47, mainW-30, 1)];
    [diviView3 setBackgroundColor:[UIColor colorWithHexString:@"#eeeeee"]];
    [itemView3 addSubview:diviView3];
    [[SINAUiviewClickLiserner alloc]viewClickFunction:itemView3 andWithBlick:^(UIView *view) {
        [weakSelf selectSpecli];
    }];
    
    //班级
    UIView *itemView4 =[[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(itemView3.frame), mainW, 48)];
    [itemView4 setBackgroundColor:[UIColor whiteColor]];
    [mainScrollView addSubview:itemView4];
    
    UILabel *titleLabel4 = [[UILabel alloc]initWithFrame:CGRectMake(15, CGRectGetHeight(itemView4.frame)/2-10, mainW-30, 21)];
    titleLabel4.text=@"班级";
    [titleLabel4 setFont:[UIFont systemFontOfSize:16]];
    titleLabel4.textColor=[UIColor colorWithHexString:@"#212121"];
    
    [itemView4 addSubview:titleLabel4];
    
    UILabel *inputTextField4 = [[UILabel alloc]initWithFrame:CGRectMake(55, CGRectGetHeight(itemView3.frame)/2-17, mainW-45, 36)];
    
    [inputTextField4 setFont:[UIFont systemFontOfSize:16]];
    inputTextField4.text=@"请选择你的班级";
    inputTextField4.textColor=[UIColor colorWithHexString:@"#878787"];
    
    self.studentSchoolClassUILabel =inputTextField4;
    
    [itemView4 addSubview:inputTextField4];
    [[SINAUiviewClickLiserner alloc]viewClickFunction:itemView4 andWithBlick:^(UIView *view) {
        [weakSelf selectClass];
    }];
    //入学年份
    UIView *itemView5 =[[UIScrollView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(itemView4.frame)+15, mainW, 48)];
    [itemView5 setBackgroundColor:[UIColor whiteColor]];
    [mainScrollView addSubview:itemView5];
    
    UILabel *titleLabel5 = [[UILabel alloc]initWithFrame:CGRectMake(15, CGRectGetHeight(itemView4.frame)/2-10, mainW-30, 21)];
    titleLabel5.text=@"入学年份";
    [titleLabel5 setFont:[UIFont systemFontOfSize:16]];
    titleLabel5.textColor=[UIColor colorWithHexString:@"#212121"];
    
    [itemView5 addSubview:titleLabel5];
    
    UILabel *inputTextField5 = [[UILabel alloc]initWithFrame:CGRectMake(85, CGRectGetHeight(itemView3.frame)/2-17, mainW-45, 36)];
    
    [inputTextField5 setFont:[UIFont systemFontOfSize:16]];
    inputTextField5.text=@"请选择你的入学年份";
    inputTextField5.textColor=[UIColor colorWithHexString:@"#878787"];
    
    self.studentSchoolYearUILabel =inputTextField5;
    
    [itemView5 addSubview:inputTextField5];
    
    [[SINAUiviewClickLiserner alloc]viewClickFunction:itemView5 andWithBlick:^(UIView *view) {
        [weakSelf selectYear];
    }];
    
    
    
    UILabel *nextLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(itemView5.frame)+48, mainW-30, 42)];
    nextLabel.text=@"下一步";
    nextLabel.textAlignment=NSTextAlignmentCenter;
    [nextLabel setFont:[UIFont systemFontOfSize:20]];
    nextLabel.textColor=[UIColor colorWithHexString:@"#ffffff"];
    [SINACircularBeadUtils makeCircularBead:1 andView:nextLabel andIsSetBackground:YES];
    [mainScrollView addSubview:nextLabel];
    
    
    //下一步
    [[SINAUiviewClickLiserner alloc]viewClickFunction:nextLabel andWithBlick:^(UIView *view) {
        [weakSelf nextFunction];
    }];
    
    
}
-(void) nextFunction{
    //学院
    NSString *schoolCollege = self.studentSchoolCollegeUILabel.text;
    //系
    NSString *schoolDepartMent = self.studentDepartmentUILabel.text;
    //专业
    NSString *schoolSpeclise = self.studentSpecialtyUILabel.text;
    //班级
    NSString *schoolClass = self.studentSchoolClassUILabel.text;
    //年份
    NSString *schoolYear= self.studentSchoolYearUILabel.text;
    
    if (schoolCollege==nil||schoolCollege.length<1||[schoolCollege isEqualToString:@"请选择你所在的学院"]) {
        WISAlertView *alertView =
        [[WISAlertView alloc]initWithTitle:@"提示" message:@"请输入你所在学院" sureBtn:@"确定" cancleBtn:nil];
        [alertView showXLAlertView];
        return;
    }
    if (schoolDepartMent==nil||schoolDepartMent.length<1||[schoolDepartMent isEqualToString:@"请选择你所在的系"]) {
        WISAlertView *alertView =
        [[WISAlertView alloc]initWithTitle:@"提示" message:@"请选择你所在系" sureBtn:@"确定" cancleBtn:nil];
        [alertView showXLAlertView];
        return;
    }
    if (schoolSpeclise==nil||schoolSpeclise.length<1||[schoolSpeclise isEqualToString:@"请选择你的专业"]) {
        WISAlertView *alertView =
        [[WISAlertView alloc]initWithTitle:@"提示" message:@"请选择你所在的班级" sureBtn:@"确定" cancleBtn:nil];
        [alertView showXLAlertView];
        return;
    }
    if (schoolClass==nil||schoolClass.length<1||[schoolClass isEqualToString:@"请选择你的班级"]) {
        WISAlertView *alertView =
        [[WISAlertView alloc]initWithTitle:@"提示" message:@"请选择你的班级" sureBtn:@"确定" cancleBtn:nil];
        [alertView showXLAlertView];
        return;
    }
    if (schoolYear==nil||schoolYear.length<1||[schoolYear isEqualToString:@"请选择你的入学年份"]) {
        WISAlertView *alertView =
        [[WISAlertView alloc]initWithTitle:@"提示" message:@"请选择你的入学年份" sureBtn:@"确定" cancleBtn:nil];
        [alertView showXLAlertView];
        return;
    }
    SINAStuApproveSchoolCountController *studentController=[[SINAStuApproveSchoolCountController alloc]init];
    studentController.studentName = self.studentName;
    studentController.currentSchooleModel = self.currentSchooleModel;
    
    studentController.selectSchoolYearModel = self.selectSchoolYearModel;
    studentController.selectSchoolClassModel = self.selectSchoolClassModel;
    studentController.selectSchoolCollegeModel = self.selectSchoolCollegeModel;
    studentController.selectDepartMentModel = self.selectDepartMentModel;
    studentController.selectSpecialtyModel = self.selectSpecialtyModel;
    [self.navigationController pushViewController:studentController animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

-(void)viewWillAppear:(BOOL)animated{
    
}

//选择学院
-(void) selectColleg{
    if (self.schoolCollegeArray.count==0) {
        [self loadingAllUniversterFunction];
    } else {
        [self askLeaveSelectTypeFunction:self.schoolCollegeArray andWithTitle:@"选择学院" andTag:101];
    }
    self.studentDepartmentUILabel.text=@"请选择你所在的系";
    self.selectDepartMentModel=nil;
     [self.schoolDepartMentArray removeAllObjects];
    
    self.studentSpecialtyUILabel.text=@"请选择你的专业";
    self.selectSpecialtyModel=nil;
    [self.schoolSpecialtyArray removeAllObjects];
    
    self.studentSchoolClassUILabel.text=@"请选择你的班级";
    self.selectSchoolClassModel=nil;
    [self.schoolSchoolClassArray removeAllObjects];
}
//选择系
-(void) selectDepartMent{
    if (self.selectSchoolCollegeModel==nil) {
        WISAlertView *alertView =
        [[WISAlertView alloc]initWithTitle:@"提示" message:@"请先选择学院" sureBtn:@"确定" cancleBtn:nil];
        [alertView showXLAlertView];
        return;
    }
    
    if (self.schoolDepartMentArray==nil||self.schoolDepartMentArray.count==0) {
        [self loadingDepartMentFunction];
    } else {
        [self askLeaveSelectTypeFunction:self.schoolDepartMentArray andWithTitle:@"选择系" andTag:102];
    }
    self.studentSpecialtyUILabel.text=@"请选择你的专业";
    self.selectSpecialtyModel=nil;
     [self.schoolSpecialtyArray removeAllObjects];
    
    self.studentSchoolClassUILabel.text=@"请选择你的班级";
    self.selectSchoolClassModel=nil;
    [self.schoolSchoolClassArray removeAllObjects];
    
   
    
}
//选择专业
-(void) selectSpecli{
    if (self.selectDepartMentModel==nil) {
        WISAlertView *alertView =
        [[WISAlertView alloc]initWithTitle:@"提示" message:@"请先选择所在系" sureBtn:@"确定" cancleBtn:nil];
        [alertView showXLAlertView];
        return;
    }
    if (self.schoolSpecialtyArray.count==0) {
        [self loadingSpecileFunction];
    } else {
        [self askLeaveSelectTypeFunction:self.schoolSpecialtyArray andWithTitle:@"选择专业" andTag:103];
    }
    
    self.studentSchoolClassUILabel.text=@"请选择你的班级";
    self.selectSchoolClassModel=nil;
}
//选择班级
-(void) selectClass{
    if (self.selectSpecialtyModel==nil) {
        WISAlertView *alertView =
        [[WISAlertView alloc]initWithTitle:@"提示" message:@"请先选择专业" sureBtn:@"确定" cancleBtn:nil];
        [alertView showXLAlertView];
        return;
    }
    if (self.schoolSchoolClassArray.count==0) {
        [self loadingSchoolClassFunction];
    } else {
        [self askLeaveSelectTypeFunction:self.schoolSchoolClassArray andWithTitle:@"选择班级" andTag:104];
    }
}
//入学年份
-(void) selectYear{
    if (self.schoolSchoolYearArray) {
        NSInteger currentYear=  [SINACalendarUtils getYear];
        
        for (NSInteger i=0; i<30; i++) {
            
            SINACommonPopModel *model =[[SINACommonPopModel alloc]init];
            model.title=[NSString stringWithFormat:@"%ld年",(currentYear-i)];
            SINASchoolClassModel *classModel = [[SINASchoolClassModel alloc]init];
            classModel.title=[NSString stringWithFormat:@"%ld年",(currentYear-i)];
            classModel.tid=[NSString stringWithFormat:@"%ld",(currentYear-i)];
            model.model = classModel;
            [self.schoolSchoolYearArray addObject:model];
        }
        
    }
    
    [self askLeaveSelectTypeFunction:self.schoolSchoolYearArray andWithTitle:@"入学年份" andTag:105];
}
-(void) askLeaveSelectTypeFunction:(NSMutableArray*) arrayData andWithTitle:(NSString *)title andTag:(NSInteger)tag{
    
    
    SINACustomModelPickView *pickerSingle = [[SINACustomModelPickView alloc]init];
    
    [pickerSingle setDataArray:arrayData];
    [pickerSingle setDefalutSelectRowStr:0];
    pickerSingle.titleLabel.text=title;
    pickerSingle.tag=tag;
    
    [pickerSingle setDelegate:self];
    
    [pickerSingle show];
    [self.view endEditing:YES];
}

#pragma mark - CustomModelPickViewDelegate method
-(void)customModelPickView:(SINACustomModelPickView *)customPickView selectedTitle:(SINACommonPopModel *)selectedModel{
    
    NSInteger tag =customPickView.tag;
    
    NSString *selectedTitle=selectedModel.title;
    SINASchoolClassModel *classmodel = (SINASchoolClassModel*)selectedModel.model;
    
    if (tag==101) {
        self.studentSchoolCollegeUILabel.text=selectedTitle;
        self.selectSchoolCollegeModel=classmodel;
        
    } else if (tag==102) {
        self.studentDepartmentUILabel.text=selectedTitle;
        self.selectDepartMentModel=classmodel;
    }else if (tag==103) {
        self.studentSpecialtyUILabel.text=selectedTitle;
        self.selectSpecialtyModel=classmodel;
    }else if (tag==104) {
        self.studentSchoolClassUILabel.text=selectedTitle;
        self.selectSchoolClassModel=classmodel;
    }else{
        self.studentSchoolYearUILabel.text=selectedTitle;
        self.selectSchoolYearModel=classmodel;
    }
}

-(void)dismissCustomPickView:(SINACustomModelPickView *)customPickView{
    
}

#pragma mark - BasePickViewDelegate method
- (void)dismissBasePickView:(SINABasePickView *)customPickView
{
    
}

//加载院
-(void) loadingAllUniversterFunction{

    [self startLoading];
    WeakSelf;
    [CXAFNHttpRequestUtils httpGetRequest:[NSString stringWithFormat:@"%@%@?univerid=%@",baseUrl,universityCollegUrl,self.currentSchooleModel.schoolId] success:^(id responseData) {
        NSString *code = responseData[@"code"];
        [weakSelf stopLoading];
        if ([code isEqualToString:@"1000"]) {
            NSMutableArray *result = responseData[@"content"];
            if (result!=nil&&result.count>0) {
                [weakSelf.schoolCollegeArray removeAllObjects];
                for (NSInteger i=0; i<result.count; i++) {
                    NSDictionary *dic = result[i];
                    SINASchoolClassModel *model = [[SINASchoolClassModel alloc]init];
                    model.title=dic[@"name"];
                    model.tid=dic[@"id"];
                    SINACommonPopModel *popModel =[[SINACommonPopModel alloc]init];
                    popModel.title=model.title;
                    popModel.model=model;
                    [weakSelf.schoolCollegeArray addObject:popModel];
                }
                [weakSelf askLeaveSelectTypeFunction:weakSelf.schoolCollegeArray andWithTitle:@"选择学院" andTag:101];
            }else{
                NSString *message =@"暂无学院信息";
                WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:message sureBtn:@"确定"
                                                                     cancleBtn:nil];
                [alertView showXLAlertView];
            }
            
            
        }else{
            NSString *message =responseData[@"message"];
            WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:message sureBtn:@"确定"
                                                                 cancleBtn:nil];
            [alertView showXLAlertView];
        }
        
    } failure:^(NSError *error, NSInteger errCode) {
        [weakSelf stopLoading];
        WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:@"获取数据验证失败" sureBtn:@"确定"
                                                             cancleBtn:nil];
        [alertView showXLAlertView];
    }];
    
}
//加载系
-(void) loadingDepartMentFunction{

    [self startLoading];
    WeakSelf;
    [CXAFNHttpRequestUtils httpGetRequest:[NSString stringWithFormat:@"%@%@?collegeid=%@",baseUrl,universityDepartMentUrl,self.selectSchoolCollegeModel.tid] success:^(id responseData) {
        NSString *code = responseData[@"code"];
        [weakSelf stopLoading];
        if ([code isEqualToString:@"1000"]) {
            NSMutableArray *result = responseData[@"content"];
            if (result!=nil&&result.count>0) {
                [weakSelf.schoolDepartMentArray removeAllObjects];
                for (NSInteger i=0; i<result.count; i++) {
                    NSDictionary *dic = result[i];
                    SINASchoolClassModel *model = [[SINASchoolClassModel alloc]init];
                    model.title=dic[@"name"];
                    model.tid=dic[@"id"];
                    SINACommonPopModel *popModel =[[SINACommonPopModel alloc]init];
                    popModel.title=model.title;
                    popModel.model=model;
                    [weakSelf.schoolDepartMentArray addObject:popModel];
                }
                [weakSelf askLeaveSelectTypeFunction:weakSelf.schoolDepartMentArray andWithTitle:@"选择系" andTag:102];
            }else{
                NSString *message =@"暂无系信息";
                WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:message sureBtn:@"确定"
                                                                     cancleBtn:nil];
                [alertView showXLAlertView];
            }
            
            
        }else{
            NSString *message =responseData[@"message"];
            WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:message sureBtn:@"确定"
                                                                 cancleBtn:nil];
            [alertView showXLAlertView];
        }
        
    } failure:^(NSError *error, NSInteger errCode) {
        [weakSelf stopLoading];
        WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:@"获取数据验证失败" sureBtn:@"确定"
                                                             cancleBtn:nil];
        [alertView showXLAlertView];
    }];
    
}
//加载专业
-(void) loadingSpecileFunction{

    [self startLoading];
    WeakSelf;
    [CXAFNHttpRequestUtils httpGetRequest:[NSString stringWithFormat:@"%@%@?collsystemid=%@",baseUrl,universitySpecileUrl,self.selectDepartMentModel.tid] success:^(id responseData) {
        NSString *code = responseData[@"code"];
        [weakSelf stopLoading];
        if ([code isEqualToString:@"1000"]) {
            NSMutableArray *result = responseData[@"content"];
            if (result!=nil&&result.count>0) {
                [weakSelf.schoolSpecialtyArray removeAllObjects];
                for (NSInteger i=0; i<result.count; i++) {
                    NSDictionary *dic = result[i];
                    SINASchoolClassModel *model = [[SINASchoolClassModel alloc]init];
                    model.title=dic[@"name"];
                    model.tid=dic[@"id"];
                    SINACommonPopModel *popModel =[[SINACommonPopModel alloc]init];
                    popModel.title=model.title;
                    popModel.model=model;
                    [weakSelf.schoolSpecialtyArray addObject:popModel];
                }
                
                [weakSelf askLeaveSelectTypeFunction:weakSelf.schoolSpecialtyArray andWithTitle:@"选择专业" andTag:103];
            }else{
                NSString *message =@"暂无专业信息";
                WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:message sureBtn:@"确定"
                                                                     cancleBtn:nil];
                [alertView showXLAlertView];
            }
            
            
        }else{
            NSString *message =responseData[@"message"];
            WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:message sureBtn:@"确定"
                                                                 cancleBtn:nil];
            [alertView showXLAlertView];
        }
        
    } failure:^(NSError *error, NSInteger errCode) {
        [weakSelf stopLoading];
        WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:@"获取数据验证失败" sureBtn:@"确定"
                                                             cancleBtn:nil];
        [alertView showXLAlertView];
    }];
    
}
//加载班级
-(void) loadingSchoolClassFunction{

    [self startLoading];
    WeakSelf;
    [CXAFNHttpRequestUtils httpGetRequest:[NSString stringWithFormat:@"%@%@?majorid=%@",baseUrl,universityClassUrl,self.selectSpecialtyModel.tid] success:^(id responseData) {
        NSString *code = responseData[@"code"];
        [weakSelf stopLoading];
        if ([code isEqualToString:@"1000"]) {
            NSMutableArray *result = responseData[@"content"];
            if (result!=nil&&result.count>0) {
                [weakSelf.schoolSchoolClassArray removeAllObjects];
                for (NSInteger i=0; i<result.count; i++) {
                    NSDictionary *dic = result[i];
                    SINASchoolClassModel *model = [[SINASchoolClassModel alloc]init];
                    model.title=dic[@"name"];
                    model.tid=dic[@"id"];
                    SINACommonPopModel *popModel =[[SINACommonPopModel alloc]init];
                    popModel.title=model.title;
                    popModel.model=model;
                    [weakSelf.schoolSchoolClassArray addObject:popModel];
                }
                
                [weakSelf askLeaveSelectTypeFunction:weakSelf.schoolSchoolClassArray andWithTitle:@"选择班级" andTag:104];
            }else{
                NSString *message =@"暂无班级信息";
                WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:message sureBtn:@"确定"
                                                                     cancleBtn:nil];
                [alertView showXLAlertView];
            }
            
            
        }else{
            NSString *message =responseData[@"message"];
            WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:message sureBtn:@"确定"
                                                                 cancleBtn:nil];
            [alertView showXLAlertView];
        }
        
    } failure:^(NSError *error, NSInteger errCode) {
        [weakSelf stopLoading];
        WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:@"获取数据验证失败" sureBtn:@"确定"
                                                             cancleBtn:nil];
        [alertView showXLAlertView];
    }];
    
}
@end
